%option noyywrap 

%{ 
    #include "string"
    #include "cstdio"
    using namespace std; 

    string keywords[]={"class","namespace","if","else","while","null","char", 
                       "int","string","private","public","protected","get", 
                       "set","value","true","false","double","return","for", 
                       "virtual","override","void","bool","foreach","in","is", 
                       "as","using","new","this",""}; 
%} 

digit            [0-9] 
alpha            [A-Za-z] 

comment          "//"([^>])*\> 
String           \"([^"]*("/\"")?)*\" 
identify         {alpha}({alpha}|{digit})* 


%% 

{comment}         {printf("<font color=green>%s</font>",yytext);} 
{identify}        { 
                         int iskey=0; 
                         for(int i=0;keywords[i]!=string("");i++) 
                         if(string(yytext)==keywords[i]) 
                         { 
                             iskey=1; 
                             break; 
                         } 
                         if(iskey) 
                             printf("<font color=blue>%s</font>",yytext); 
                         else 
                             printf("%s",yytext); 
                   } 
{String}          {printf("%s",yytext);} 

%% 

int main() 
{ 
    yylex(); 
}